[mypy] Enable mypy for some files in OV and ONNX backends#4099
Open
AlexanderDokuchaev wants to merge 5 commits into
Open
[mypy] Enable mypy for some files in OV and ONNX backends#4099AlexanderDokuchaev wants to merge 5 commits into
AlexanderDokuchaev wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to expand strict mypy coverage for parts of the OpenVINO and ONNX backends by (1) installing the required backend dependencies in the mypy CI workflow and (2) tightening/adding type annotations in several backend modules, while reducing the mypy exclude list.
Changes:
- Update mypy CI workflow to install
onnx,onnxruntime, andopenvinoso backend imports can be type-checked. - Reduce mypy
excludelist inpyproject.tomlto enable checking of additional OV/ONNX files. - Add/adjust type annotations across several OV/ONNX backend modules to satisfy strict mypy.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/nncf/openvino/rt_info.py | Tighten parameter/collection type hints for RT info dumping helpers. |
| src/nncf/openvino/quantization/default_quantization.py | Add explicit dict type for trait→metatype mapping. |
| src/nncf/openvino/quantization/backend_parameters.py | Suppress no-any-return for backend-param access (recommend removing ignore via casting). |
| src/nncf/openvino/graph/transformations/commands.py | Improve typing for equality and numpy array parameters in OV transformation commands. |
| src/nncf/openvino/graph/node_utils.py | Refine metatype parameter typing for weighted-layer attribute extraction. |
| src/nncf/openvino/graph/model_builder.py | Add return type for __init__ and annotate deque element type. |
| src/nncf/openvino/graph/layout.py | Fix tuple return types to variadic tuple typing and refine metatype typing. |
| src/nncf/openvino/engine.py | Add typed numpy input/output signatures for OV inference engines. |
| src/nncf/openvino/cpu_info.py | Add no-any-return ignores for OpenVINO property getters (recommend converting to str). |
| src/nncf/onnx/graph/transformations/commands.py | Add typing import and refine numpy array typing; adjust __eq__ signature. |
| src/nncf/onnx/graph/transformations/command_creation.py | Refine numpy array typing in command creation helpers. |
| src/nncf/onnx/graph/onnx_helper.py | Refine return/variable typing for edge/tensor helpers and packing utilities. |
| src/nncf/onnx/graph/model_transformer.py | Make transformer generic over onnx.ModelProto and refine initializer typing. |
| src/nncf/onnx/engine.py | Refine ONNX engine I/O typing for inference. |
| src/nncf/common/utils/backend.py | Remove mypy ignore from onnx import now that CI installs it. |
| src/nncf/common/factory.py | Remove mypy ignore from onnx import used for backend dispatch. |
| pyproject.toml | Reduce mypy exclude list to enable checking of additional backend files. |
| .github/workflows/mypy.yml | Install backend deps (onnx, onnxruntime, openvino) in mypy workflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Reason for changes
Code quality
Related tickets
Tests